<?php

namespace App\Store\Validate\Goods;

use App\Common\Validate\BaseValidate;

/**
 * 权限组验证器
 */
class GoodsStockin extends BaseValidate
{

    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];


    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') { //新增入库单
            $this->rule = [
                'store_id' => 'required|integer|gt:0',
                'goods_sn_code' => 'required',
                'goods_style_id' => 'required|integer|gt:0',
                'goods_name' => 'required',
                'goods_category_id' => 'required|integer|gt:0',
                'count' => 'required|integer|gt:0',
                'is_code_more'=>'required|in:1,2',
            ];
            $this->message = [
                'store_id.required' => '门店未选择',
                'store_id.integer' => '门店参数错误',
                'store_id.gt' => '门店参数错误',
                'goods_sn_code.required' => '商品编号未填写',
                'goods_style_id.required' => '款式未选择',
                'goods_style_id.integer' => '款式参数错误',
                'goods_style_id.gt' => '款式参数错误',
                'goods_name.required' => '商品名称未填写',
                'goods_category_id.required' => '商品类别未选择',
                'goods_category_id.integer' => '商品类别参数错误',
                'goods_category_id.gt' => '商品类别参数错误',
                'count.required' => '商品数量未填写',
                'count.integer' => '商品数量参数错误',
                'count.gt' => '商品数量参数错误',
                'is_code_more.required' => '一码多货未选择',
                'is_code_more.in'       => '一码多货参数错误'
            ];
        } elseif ($doaction == 'edit') { //编辑单条数据
            $this->rule = [
                'id' => 'required|integer|gt:0',
                'goods_sn_code' => 'required',
                'goods_style_id' => 'required|integer|gt:0',
                'goods_name' => 'required',
                'goods_category_id' => 'required|integer|gt:0',
                'count' => 'required|integer|gt:0',
                'is_code_more'=>'required|in:1,2',
            ];
            $this->message = [
                'id.required' => '参数错误',
                'id.integer' => '参数错误',
                'id.gt' => '参数错误',
                'goods_sn_code.required' => '商品编号未填写',
                'goods_style_id.required' => '款式未选择',
                'goods_style_id.integer' => '款式参数错误',
                'goods_style_id.gt' => '款式参数错误',
                'goods_name.required' => '商品名称未填写',
                'goods_category_id.required' => '商品类别未选择',
                'goods_category_id.integer' => '商品类别参数错误',
                'goods_category_id.gt' => '商品类别参数错误',
                'count.required' => '商品数量未填写',
                'count.integer' => '商品数量参数错误',
                'count.gt' => '商品数量参数错误',
                'is_code_more.required' => '一码多货未选择',
                'is_code_more.in'       => '一码多货参数错误'
            ];
        }elseif($doaction=='editimport'){
            $this->rule = [
                'goods_sn_code' => 'required',
                'goods_style_id' => 'required|integer|gt:0',
                'goods_name' => 'required',
                'goods_category_id' => 'required|integer|gt:0',
                'count' => 'required|integer',
                'is_code_more'=>'required|in:1,2',
            ];
            $this->message = [
                'goods_sn_code.required' => '商品编号未填写',
                'goods_style_id.required' => '款式未选择',
                'goods_style_id.integer' => '款式参数错误',
                'goods_style_id.gt' => '款式参数错误',
                'goods_name.required' => '商品名称未填写',
                'goods_category_id.required' => '商品类别未选择',
                'goods_category_id.integer' => '商品类别参数错误',
                'goods_category_id.gt' => '商品类别参数错误',
                'count.required' => '商品数量未填写',
                'count.integer' => '商品数量参数错误',
                'is_code_more.required' => '一码多货未选择',
                'is_code_more.in'       => '一码多货参数错误'
            ];
        }
    }
}
